package com.miao.teacher.adapter;

import java.util.List;

import com.miao.teacher.adapter.OrderAdapter.ViewHolder;
import com.miao.teacher.models.FeedBack;
import com.miao.teacher.models.PullOrder;
import com.miao.teacher.ui.R;
import com.miao.teacher.utils.ConvertUtils;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.RatingBar;
import android.widget.TextView;

public class FeedbackAdapter extends BaseAdapter{

	private Context context=null;
	private LayoutInflater mInflater;
	private List<FeedBack> mList=null;
	public FeedbackAdapter(Context c,List<FeedBack> list)
	{
		context=c;
		mList=list;
		mInflater = (LayoutInflater) context
		.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
	}
	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		if(mList==null)
		{
			return 0;
		}
		return mList.size();
	}

	@Override
	public Object getItem(int position) {
		// TODO Auto-generated method stub
		if(mList==null)
		{
			return null;
		}
		return mList.get(position);
	}

	@Override
	public long getItemId(int position) {
		// TODO Auto-generated method stub
		return 0;
	}

	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		// TODO Auto-generated method stub
		ViewHolder holder = null;
		if (convertView == null) {
			convertView = mInflater.inflate(R.layout.item_feedback, null);
			holder = new ViewHolder();
			holder.tvOrder=(TextView)convertView.findViewById(R.id.tvOrder);
			holder.tvTitle=(TextView)convertView.findViewById(R.id.tvTitle);
			holder.tvMsg=(TextView)convertView.findViewById(R.id.tv_Msg);
			holder.rBar=(RatingBar)convertView.findViewById(R.id.rBar);
			convertView.setTag(holder);
		}else
		{
			holder = (ViewHolder) convertView.getTag();
		}
		FeedBack obj=mList.get(position);
		holder.tvOrder.setText((position+1)+"");
		holder.tvTitle.setText(obj.title);
		holder.tvMsg.setText(obj.feedback_msg);
		holder.rBar.setProgress(obj.feedback_rate);
		holder.rBar.setEnabled(false);
		return convertView;
	}
	static class ViewHolder
	{
		TextView tvOrder;
		TextView tvTitle;
		TextView tvMsg;
		RatingBar rBar;
	}
}
